//
//  HeadTitleView.m
//  DZZTravel
//
//  Created by 赵国栋 on 16/7/16.
//  Copyright © 2016年 Eason. All rights reserved.
//

#import "HeadTitleView.h"

@interface HeadTitleView ()
@property (nonatomic ,strong)UIButton *btn1;
@property (nonatomic ,strong)UIButton *btn2;
@property (nonatomic ,strong)UIView *followView;
@end

@implementation HeadTitleView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
    [self setHotAndAroundPlay];
        
    }
    return self;
}


- (void)setHotAndAroundPlay{
    self.btn1 = [[UIButton alloc]initWithFrame:CGRectMake(self.frame.size.width/2-100, 10, 60, 30)];
    [self.btn1 setTitle:@"套餐" forState:UIControlStateNormal];
    self.followView = [[UIView alloc]initWithFrame:CGRectMake(self.btn1.x, self.btn1.y+self.btn1.height-1, 60, 2)];
    self.followView.backgroundColor = [UIColor redColor];
    
    self.btn2 = [[UIButton alloc]initWithFrame:CGRectMake(self.frame.size.width/2+10, 10, 80, 30)];
    
    [self.btn2 setTitle:@"门票" forState:UIControlStateNormal];
    
    [self.btn1 addTarget:self action:@selector(btn1Action) forControlEvents:UIControlEventTouchUpInside];
    [self.btn2 addTarget:self action:@selector(btn2Action) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self addSubview:self.followView];
    [self addSubview:self.btn1];
    [self addSubview:self.btn2];
}


- (void)btn1Action{
 
 
    [self change:self.btn1];
}


- (void)btn2Action{

    [self change:self.btn2];
}

- (void)change:(UIButton *)btn{
    self.btn1.enabled = YES;
    
    self.btn2.enabled = YES;
    btn.enabled = NO;
    
    CGRect oldRect = self.followView.frame;
    oldRect.size.width = btn.width;
    oldRect.origin.x = btn.x;
    [UIView animateWithDuration:0.25 animations:^{
        self.followView.frame = oldRect;
    }];
}
@end
